class GamePageController < ApplicationController
  def new
    @queue ||= Queue.new
  end

  def add(message)
    self.messages= "";
   @queue << message
   start_pushing_thread
  end
private

  def start_pushing_thread
   return if @pushing_thread
   @pushing_thread = Thread.new do
     loop do
          # pop will block until there are queue items available
          self.messages  = self.messages + "\n" + @queue.pop
       #if items.size > 24
       #  SdbWrapper::batch_log_to_sdb(items,'tracking_domain')
       #  items.clear
       #end
     end
   end
   flash.now.alert = self.messages
   render "new"
  end
  
  def update_queue(message)
    @game_queue.add(message)
  end
end
